home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 576-600 / 581 / prism / source / source.lzh / prism.c < prev    next >
C/C++ Source or Header  |  1991-12-06  |  47KB  |  1,621 lines

  1. /***********************************************************************\
  2. *               Prism - THE Amiga ANSI Animator        *
  3. *                By: Colin Vernon             *
  4. *               Prism 1.00 - October 15,1989            *
  5. *                                    *
  6. *            Version 1.2 by Chris Timmerberg, 10/01/90        *
  7. * New improved load routine, handles more esc seq, and handles the rest    *
  8. * better. Sprite definitions were given CHIP keyword, no longer needed    *
  9. * to copy to Chip. For some reason BackStdOut didnt work so I replaced    *
  10. * with opening a new window. Now uses function prototypes for smaller/    *
  11. * faster code. Fixed so it actually works on my computer. Not sure what    *
  12. * that one was!                                *
  13. *                                    *
  14. *            Version 1.3 by Chris Timmerberg, 01/31/91        *
  15. * Fixed save problems relating to intensity, & improved save efficiency    *
  16. * Eliminated some redundant assignments as suggested by global optimizer*
  17. *                                    *
  18. *           Version 1.3I by Chris Timmerberg, 03/31/91        *
  19. * Bumped line count up to 25 (WHY did Colin have 24 lines???) Interlace    *
  20. * (50 line) mode added for those users of my other program, toans. Went    *
  21. * through and replaced chars with UBYTES and (most) ints with USHORTS.    *
  22. * Removed a ^ on line 1060. Still not sure why Colin had it there.    *
  23. *                                    *
  24. *             Version 1.4 by Syd L. Bolton, 11/16/91        *
  25. * Changed to a totally different File Requester, which allows VOLUME    *
  26. * names to be clicked on.  Re-wrote a good chunk of the source code to  *
  27. * make it MUCH more readable.  Also cut down source size because a lot  *
  28. * of the White-Space was SPACES instead of TABS. Made some changes so   *
  29. * that it would compile under Manx 5.0 (only needed to change the       *
  30. * #includes, and put feof in the load routine).    Added the configure menu*
  31. * and the menus to choose SPEED EMULATION (2400 baud, 1200 baud, etc.)  *
  32. * Also made it optional to put a CLEAR at the beginning of the file (in *
  33. * case you're doing an animation that already has stuff on the screen)  *
  34. * Added a new gadget at the bottom that allows you to constantly be in  *
  35. * BACKGROUND COLOR mode, in case you change your BG color a lot.        *
  36. \***********************************************************************/
  37.  
  38. #include <stdio.h>
  39. #include <string.h>
  40. #include <stdlib.h>
  41.  
  42. #include <functions.h>
  43. #include <libraries/dos.h>
  44. #include <exec/exec.h>
  45. #include <exec/types.h>
  46. #include <exec/memory.h>
  47. #include <intuition/intuition.h>
  48. #include <graphics/sprite.h>
  49.  
  50. #define MAXWIDTH 80
  51. #define MINHEIGHT 1
  52. #define MINWIDTH 1
  53. #define MAXCHARSETS 12
  54. #define SPACE 0x20
  55. #define BACKSPACE 0x08
  56. #define LINEFEED 0x0a
  57. #define FORMFEED 0x0c
  58. #define RETURN 0x0d
  59. #define TAB 0x09
  60. #define CURSOR_UP 'A'
  61. #define CURSOR_DOWN 'B'
  62. #define CURSOR_RIGHT 'C'
  63. #define CURSOR_LEFT 'D'
  64. #define ESC 0x1b
  65. #define MAXINPUTLEN 80
  66.  
  67. struct ANSI { 
  68.     struct ANSI *next;
  69.     struct ANSI *previous;
  70.     UBYTE x,y,fcolor,bcolor,letter,pad;
  71.     };
  72.  
  73. static UBYTE Titlebar[] = "Prism 1.4 by Syd L. Bolton, Chris Timmerberg, original by Colin Vernon";
  74. struct DOSBase *DOSBase;
  75. struct IntuitionBase *IntuitionBase;
  76. struct GfxBase *GfxBase;
  77. struct DiskfontBase *DiskfontBase;
  78. struct Screen *WorkScreen;
  79. struct Window *WorkWindow;
  80. struct Window *Gads;
  81. struct Window *ReqWindow;
  82. struct IntuiMessage *message;
  83. struct IOStdReq ioStdReq;
  84. struct Library *ConsoleDevice = 0;
  85. struct SimpleSprite Cursor;
  86. struct RastPort *rport;
  87.  
  88. /************************** Sprite Defs *********************************/
  89. UWORD NormalCursor[] = {
  90.     0,0,
  91.     0xf000,0xf000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  92.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xf000,0xf000,
  93.     0,0
  94.     };
  95. UWORD InterlaceCursor[]= {
  96.     0,0,
  97.     0xf000,0xf000,0x0000,0x0000,0x0000,0x0000,0xf000,0xf000,
  98.     0,0
  99.     };
  100. UWORD ChipBlank[] ={
  101.     0,0,
  102.     0x0000, 0x0000,    0x0000, 0x0000,    0x0000, 0x0000,    0x0000, 0x0000,
  103.     0x0000, 0x0000,    0x0000, 0x0000,    0x0000, 0x0000,    0x0000, 0x0000,
  104.     0,0
  105. };
  106. WORD Spr1;
  107. /*************************** Gadget Definitions **************************/
  108. struct IntuiText Color15 ={0,15,JAM2,0,0,0," 15 ",0,};
  109. struct IntuiText Color14 ={0,14,JAM2,0,0,0," 14 ",0,};
  110. struct IntuiText Color13 ={0,13,JAM2,0,0,0," 13 ",0,};
  111. struct IntuiText Color12 ={0,12,JAM2,0,0,0," 12 ",0,};
  112. struct IntuiText Color11 ={0,11,JAM2,0,0,0," 11 ",0,};
  113. struct IntuiText Color10 ={0,10,JAM2,0,0,0," 10 ",0,};
  114. struct IntuiText Color9 ={0,9,JAM2,0,0,0,"  9 ",0,};
  115. struct IntuiText Color8 ={0,8,JAM2,0,0,0,"  8 ",0,};
  116. struct IntuiText Color7 ={0,7,JAM2,0,0,0,"  7 ",0,};
  117. struct IntuiText Color6 ={0,6,JAM2,0,0,0,"  6 ",0,};
  118. struct IntuiText Color5 ={0,5,JAM2,0,0,0,"  5 ",0,};
  119. struct IntuiText Color4 ={0,4,JAM2,0,0,0,"  4 ",0,};
  120. struct IntuiText Color3 ={0,3,JAM2,0,0,0,"  3 ",0,};
  121. struct IntuiText Color2 ={0,2,JAM2,0,0,0,"  2 ",0,};
  122. struct IntuiText Color1 ={0,1,JAM2,0,0,0,"  1 ",0,};
  123. struct IntuiText Color0 ={1,0,JAM2,0,0,0,"  0 ",0,};
  124.  
  125. struct IntuiText ForeBack2 = {
  126.     15,0,JAM2,7,10,0,(UBYTE *)"Col",0
  127.     };
  128. struct IntuiText ForeBackText = {
  129.     15,0,JAM2,3,2,0,(UBYTE *)"Back",&ForeBack2
  130.     };
  131. struct Gadget ForeBackGadget = {
  132.     0,553,10,38,19,
  133.     GADGHCOMP | SELECTED,RELVERIFY,BOOLGADGET,
  134.     0,0,&ForeBackText,0,0,17,0
  135.     };
  136. struct IntuiText FBStickText = {
  137.     15,0,JAM2,3,6,0,(UBYTE *)"Fore",0
  138.     };
  139. struct Gadget FBStickGadget = {
  140.     &ForeBackGadget,597,10,38,19,
  141.     GADGHCOMP|SELECTED,RELVERIFY,BOOLGADGET,
  142.     0,0,&FBStickText,0,0,18,0
  143.     };
  144. struct Gadget SelColor15 = {
  145.     &FBStickGadget,512,11,32,8,
  146.     GADGHCOMP,RELVERIFY|GADGIMMEDIATE,BOOLGADGET,
  147.     0,0,&Color15,0,0,16,0
  148.     };
  149. struct Gadget SelColor14 = {
  150.     &SelColor15,478,11,32,8,
  151.     GADGHCOMP,RELVERIFY|GADGIMMEDIATE,BOOLGADGET,
  152.     0,0,&Color14,0,0,15,0
  153.     };
  154. struct Gadget SelColor13 = {
  155.     &SelColor14,444,11,32,8,
  156.     GADGHCOMP,RELVERIFY|GADGIMMEDIATE,BOOLGADGET,
  157.     0,0,&Color13,0,0,14,0
  158.     };
  159. struct Gadget SelColor12 = {
  160.     &SelColor13,410,11,32,8,
  161.     GADGHCOMP,RELVERIFY|GADGIMMEDIATE,BOOLGADGET,
  162.     0,0,&Color12,0,0,13,0
  163.     };
  164. struct Gadget SelColor11 = {
  165.     &SelColor12,376,11,32,8,
  166.     GADGHCOMP,RELVERIFY|GADGIMMEDIATE,BOOLGADGET,
  167.     0,0,&Color11,0,0,12,0
  168.     };
  169. struct Gadget SelColor10 = {
  170.     &SelColor11,342,11,32,8,
  171.     GADGHCOMP,RELVERIFY|GADGIMMEDIATE,BOOLGADGET,
  172.     0,0,&Color10,0,0,11,0
  173.     };
  174. struct Gadget SelColor9 = {
  175.     &SelColor10,308,11,32,8,
  176.     GADGHCOMP,RELVERIFY|GADGIMMEDIATE,BOOLGADGET,
  177.     0,0,&Color9,0,0,10,0
  178.     };
  179. struct Gadget SelColor8 = {
  180.     &SelColor9,274,11,32,8,
  181.     GADGHCOMP,RELVERIFY|GADGIMMEDIATE,BOOLGADGET,
  182.     0,0,&Color8,0,0,9,0
  183.     };
  184. struct Gadget SelColor7 = {
  185.     &SelColor8,240,11,32,8,
  186.     GADGHCOMP,RELVERIFY|GADGIMMEDIATE,BOOLGADGET,
  187.     0,0,&Color7,0,0,8,0
  188.     };
  189. struct Gadget SelColor6 = {
  190.     &SelColor7,206,11,32,8,
  191.     GADGHCOMP,RELVERIFY|GADGIMMEDIATE,BOOLGADGET,
  192.     0,0,&Color6,0,0,7,0
  193.     };
  194. struct Gadget SelColor5 = {
  195.     &SelColor6,172,11,32,8,
  196.     GADGHCOMP,RELVERIFY|GADGIMMEDIATE,BOOLGADGET,
  197.     0,0,&Color5,0,0,6,0
  198.     };
  199. struct Gadget SelColor4 = {
  200.     &SelColor5,138,11,32,8,
  201.     GADGHCOMP,RELVERIFY|GADGIMMEDIATE,BOOLGADGET,
  202.     0,0,&Color4,0,0,5,0
  203.     };
  204. struct Gadget SelColor3 = {
  205.     &SelColor4,104,11,32,8,
  206.     GADGHCOMP,RELVERIFY|GADGIMMEDIATE,BOOLGADGET,
  207.     0,0,&Color3,0,0,4,0
  208.     };
  209. struct Gadget SelColor2 = {
  210.     &SelColor3,70,11,32,8,
  211.     GADGHCOMP,RELVERIFY|GADGIMMEDIATE,BOOLGADGET,
  212.     0,0,&Color2,0,0,3,0
  213.     };
  214. struct Gadget SelColor1 = {
  215.     &SelColor2,36,11,32,8, 
  216.     GADGHCOMP,RELVERIFY|GADGIMMEDIATE,BOOLGADGET,
  217.     0,0,&Color1,0,0,2,0
  218.     };
  219. struct Gadget SelColor0 = {
  220.     &SelColor1,2,11,32,8,
  221.     GADGHCOMP,RELVERIFY|GADGIMMEDIATE,BOOLGADGET,
  222.     0,0,&Color0,0,0,1,0
  223.     };
  224. /**** REQUESTERS ****/
  225. struct IntuiText AboutProg7Text = {
  226.     4,7,JAM2,30,59,0,"Syd Bolton of Legendary Design Technologies Inc.",0
  227.     };
  228. struct IntuiText AboutProg6Text = {
  229.     4,7,JAM2,30,50,0,"Enhancements to this program by Chris Timmerberg, and",&AboutProg7Text
  230.     };
  231. struct IntuiText AboutProg5Text = {
  232.     4,7,JAM2,30,41,0,"are not modified.  This version of Prism is public domain.",&AboutProg6Text
  233.     };
  234. struct IntuiText AboutProg4Text = {
  235.     4,7,JAM2,30,32,0,"distributed as long as the original files in the archive",&AboutProg5Text
  236.     };
  237. struct IntuiText AboutProg3Text = {
  238.     4,7,JAM2,30,23,0,"Prism is an ANSI animator for the Amiga.  It can be",&AboutProg4Text
  239.     };
  240. struct IntuiText AboutProgText = {
  241.     1,7,JAM1,205,9,0,"Prism by Colin Vernon",&AboutProg3Text
  242.     };
  243.  
  244. /***** The Requester Window *****/
  245. struct NewWindow RequesterWindow = {
  246.     135,50,370,100,0,7,GADGETUP,SIMPLE_REFRESH|ACTIVATE,0,0,0,0,0,0,0,0,0,
  247.     CUSTOMSCREEN,
  248.     };
  249. struct Requester FileSelectBox;
  250. struct TextAttr WorkFont = {
  251.     (STRPTR)"ibm.font",
  252.     8,0,0
  253.     };
  254. struct TextAttr DisplayFont = {
  255.     (STRPTR)"topaz.font",TOPAZ_EIGHTY,FS_NORMAL,FPF_ROMFONT
  256.     };
  257. struct NewScreen FirstWorkScreen = {
  258.     0,0,640,210,4,4,7,HIRES|SPRITES,CUSTOMSCREEN,&DisplayFont,Titlebar,0,0
  259.     };
  260. struct NewWindow FirstWorkWindow = {
  261.     0,10,640,200,4,7,MOUSEBUTTONS|RAWKEY|MENUPICK,
  262.     SMART_REFRESH|ACTIVATE|BORDERLESS|GIMMEZEROZERO,
  263.     0,0,0,0,0,0,0,0,0,CUSTOMSCREEN
  264.     };
  265. struct NewWindow GadgetWindow = {
  266.     0,170,640,30,4,7,GADGETUP|ACTIVEWINDOW,SMART_REFRESH|WINDOWDRAG,
  267.     &SelColor0,0,"Gadget Box",0,0,0,0,0,0,CUSTOMSCREEN
  268.     };
  269. struct InputEvent inputEvent = {
  270.     0,IECLASS_RAWKEY,0,0,0
  271.     };
  272. UWORD AtrColors[16] = {
  273.     0x000, 0xA00, 0x0A0, 0xA60, 0x00A, 0xA0A, 0x0AA, 0xBBB,
  274.     0x666, 0xF00, 0x0F0, 0xFF0, 0x00F, 0xF0F, 0x0FF, 0xFFF    
  275.     };
  276. /**************************** Menu Definition **************************/
  277. struct IntuiText ForplanesText = {4,7,JAM2,18,1,&DisplayFont,"16 Colors",0};
  278. struct IntuiText ThreeplanesText = {4,7,JAM2,18,1,&DisplayFont,"8 Colors",0};
  279. struct IntuiText TwoplanesText = {4,7,JAM2,18,1,&DisplayFont,"4 Colors",0};
  280. struct IntuiText ColorsText = {4,7,JAM2,0,1,&DisplayFont,"Colors   >",0};
  281. struct IntuiText QuitText = {4,7,JAM2,0,1,&DisplayFont,"Quit",0};
  282. struct IntuiText AppendText = {4,7,JAM2,0,1,&DisplayFont,"Append   >",0};
  283. struct IntuiText SaveText = {4,7,JAM2,0,1,&DisplayFont,"Save...",0};
  284. struct IntuiText LoadText = {4,7,JAM2,0,1,&DisplayFont,"Load...",0};
  285. struct IntuiText ClearText = {4,7,JAM2,0,1,&DisplayFont,"Clear",0};
  286. struct IntuiText PlaybackText = {4,7,JAM2,0,1,&DisplayFont,"Playback",0};
  287. struct IntuiText AboutText = {4,7,JAM2,0,1,&DisplayFont,"About",0};
  288. struct IntuiText InterlaceText = {4,7,JAM2,18,1,&DisplayFont,"Lace",0};
  289. struct IntuiText ConfigText = {4,7,JAM2,0,1,&DisplayFont,"Configure...",0};
  290. struct IntuiText TFBaudText = {4,7,JAM2,18,1,&DisplayFont,"2400 Baud",0};
  291. struct IntuiText TWBaudText = {4,7,JAM2,18,1,&DisplayFont,"1200 Baud",0};
  292. struct IntuiText FastestText = {4,7,JAM2,18,1,&DisplayFont,"FASTEST",0};
  293. struct IntuiText SpeedText = {4,7,JAM2,0,1,&DisplayFont,"Speed    >",0};
  294. struct IntuiText SClearText = {4,7,JAM2,18,1,&DisplayFont,"SClear",0};
  295.  
  296. struct MenuItem Configure = {
  297.     0,0,40,110,10,ITEMTEXT|ITEMENABLED|HIGHCOMP,0,(APTR)&ConfigText,0,0,0,0
  298.     };
  299. struct MenuItem SClear = {
  300.     &Configure,0,30,110,10,ITEMTEXT|ITEMENABLED|HIGHCOMP|CHECKIT|COMMSEQ,0,
  301.     (APTR)&SClearText,0,'R',0,0
  302.     };
  303. struct MenuItem Interlace = {
  304.     &SClear,0,20,110,10,ITEMTEXT|ITEMENABLED|HIGHCOMP|COMMSEQ|CHECKIT, 0,
  305.     (APTR)&InterlaceText,0,'I',0,0
  306.     };
  307. struct MenuItem Fastest = {
  308.     0,80,20,100,10,ITEMTEXT|ITEMENABLED|HIGHCOMP|CHECKIT|CHECKED,
  309.     3,(APTR)&FastestText,0,0,0,0
  310.     };
  311. struct MenuItem TFBaud = {
  312.     &Fastest,80,10,100,10,ITEMTEXT|ITEMENABLED|HIGHCOMP|CHECKIT,
  313.     5,(APTR)&TFBaudText,0,0,0,0
  314.     };
  315. struct MenuItem TWBaud = {
  316.     &TFBaud,80,0,100,10,ITEMTEXT|ITEMENABLED|HIGHCOMP|CHECKIT,
  317.     5,(APTR)&TWBaudText,0,0,0,0
  318.     };
  319. struct MenuItem Speed ={
  320.     &Interlace,0,10,110,10,ITEMTEXT|ITEMENABLED|HIGHCOMP,0,
  321.     (APTR)&SpeedText,0,0,&TWBaud,0
  322.     };
  323. struct MenuItem Forplanes = {
  324.     0,80,20,130,10,ITEMTEXT|ITEMENABLED|HIGHCOMP|COMMSEQ|
  325.     CHECKIT|CHECKED,3,(APTR)&ForplanesText,0,'4',0,0
  326.     };
  327. struct MenuItem Threeplanes = {
  328.     &Forplanes,80,10,130,10,ITEMTEXT|ITEMENABLED|HIGHCOMP|COMMSEQ|
  329.     CHECKIT,5,(APTR)&ThreeplanesText,0,'3',0,0
  330.     };
  331. struct MenuItem Twoplanes = {
  332.     &Threeplanes,80,0,130,10,ITEMTEXT|ITEMENABLED|HIGHCOMP|COMMSEQ|
  333.     CHECKIT,6,(APTR)&TwoplanesText,0,'2',0,0
  334.     };
  335. struct MenuItem Colors ={
  336.     &Speed,0,0,110,10,ITEMTEXT|ITEMENABLED|HIGHCOMP,0,
  337.     (APTR)&ColorsText,0,0,&Twoplanes,0
  338.     };
  339. struct MenuItem Quit = {
  340.     0,0,60,120,10,ITEMTEXT|ITEMENABLED|HIGHBOX|COMMSEQ,0,
  341.     (APTR)&QuitText,0,'Q',0,0
  342.     };
  343. struct MenuItem AppSave = {
  344.     0,80,10,60,10,ITEMTEXT|ITEMENABLED|HIGHCOMP,0,
  345.     (APTR)&SaveText,0,0,0,0
  346.     };
  347. struct MenuItem AppLoad = {
  348.     &AppSave,80,0,60,10,ITEMTEXT|ITEMENABLED|HIGHCOMP,0,
  349.     (APTR)&LoadText,0,0,0,0
  350.     };
  351. struct MenuItem Append = {
  352.     &Quit,0,50,120,10,ITEMTEXT|ITEMENABLED|HIGHCOMP,0,
  353.     (APTR)&AppendText,0,0,&AppLoad,0
  354.     };
  355. struct MenuItem Save = {
  356.     &Append,0,40,120,10,ITEMTEXT|ITEMENABLED|HIGHCOMP|COMMSEQ,0,
  357.     (APTR)&SaveText,0,'S',0,0
  358.     };
  359. struct MenuItem Load = {
  360.     &Save,0,30,120,10,ITEMTEXT|ITEMENABLED|HIGHCOMP|COMMSEQ,0,
  361.     (APTR)&LoadText,0,'L',0,0
  362.     };
  363. struct MenuItem Clear = {
  364.     &Load,0,20,120,10,ITEMTEXT|ITEMENABLED|HIGHCOMP|COMMSEQ,0,
  365.     (APTR)&ClearText,0,'C',0,0
  366.     };    
  367. struct MenuItem Playback = {
  368.     &Clear,0,10,120,10,ITEMTEXT|ITEMENABLED|HIGHCOMP|COMMSEQ,0,
  369.     (APTR)&PlaybackText,0,'P',0,0
  370.     };
  371. struct MenuItem About = {
  372.     &Playback,0,0,120,10,ITEMTEXT|ITEMENABLED|HIGHCOMP,0,
  373.     (APTR)&AboutText,0,0,0,0
  374.     };
  375. struct Menu Setup = {
  376.     0,100,0,100,10,MENUENABLED,"Setup",&Colors
  377.     };
  378. struct Menu Project = {
  379.     &Setup,0,0,100,10,MENUENABLED,"Project",&About
  380. };
  381.  
  382. UBYTE Buffer[MAXINPUTLEN];
  383. USHORT scanner;
  384. struct ANSI storage = { 0,0,-1,-1,-1,-1,0 };
  385. struct ANSI *sdlstptr, *lastptr, *middle, *front, *back;
  386. struct TextFont *TFont;
  387. USHORT length = 0,position = 0;    /* used to display where editor is */
  388. USHORT cx = 1, cy = 1;        /* cursor co-ordinates */
  389. USHORT maxheight=25;
  390. BOOL changes = FALSE;
  391. static UBYTE funckey[MAXCHARSETS][8] = {
  392.     {0xb3, 0xc4, 0xc5, 0xc0, 0xd9, 0xda, 0xbf, 0xd8},
  393.     {0xba, 0xcd, 0xce, 0xc8, 0xbc, 0xc9, 0xbb, 0xd7},
  394.     {0xc1, 0xc2, 0xb4, 0xc3, 0xca, 0xcb, 0xb9, 0xcc},
  395.     {0xbe, 0xd4, 0xb8, 0xd5, 0xbd, 0xd3, 0xb7, 0xd6},
  396.     {0xd0, 0xd2, 0xb6, 0xc7, 0xcf, 0xd1, 0xb5, 0xc6},
  397.     {0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xb0, 0xb1, 0xb2},
  398.     {0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7},
  399.     {0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7},
  400.     {0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef},
  401.     {0xf0, 0xf1, 0xf2, 0xf3, 0xfe, 0xf6, 0xfd, 0xfb},
  402.     {0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf},
  403.     {0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfc}
  404. };
  405. UBYTE path[512] = "";
  406. UBYTE filename[33] = "Unnamed.ans";
  407. long _stack = 10000;        /* my Load-And-Stay Resident stack size */
  408. UBYTE *_procname = "Prism";    /* my proceedure name */
  409. long _priority = 0;        /* A regular priority */
  410. long _BackGroundIO = 0;        /* If this != 0, I can Write() to CLI but
  411.                    I must Close(_Backstdout) when done */
  412. extern BPTR _Backstdout;    /* CLI file handle */
  413.  
  414. struct IntuiText GeneralText = {
  415.     1,0,JAM2,0,0,&WorkFont,Buffer,0
  416. };
  417.  
  418. int windowtopedge,windowleftedge,dir_only=0,read_dir=1;  /* new to 1.4 */
  419. int cmode=0,sclearmode=1,lacemode=0,tabspace=8,speed=0,maxcolor=15;
  420.  
  421. #include "pointer.c"
  422.  
  423. main()
  424. {
  425. ULONG MessageClass;
  426. USHORT code, qualifier;
  427. UBYTE memusestr[81];        /* display position and length */
  428. SHORT mx, my;            /* mouse co-ordinates */
  429. USHORT fcolor = 7;        /* initialize forground color */
  430. USHORT bcolor = 0;
  431. USHORT tabplace, tempnum, jx, jy;
  432. SHORT presset = 0;
  433. BOOL mbuttons = FALSE, BGmode = FALSE, gadwinfront = TRUE;
  434. struct Gadget *GadgetPtr;
  435. USHORT GadgetID;
  436.     
  437. load_config();
  438. OpenLibs();
  439. lastptr = &storage;
  440. middle = lastptr;
  441.     
  442. FOREVER {
  443. mx = (SHORT) (WorkWindow->GZZMouseX)/8+1;
  444. my = (SHORT) (WorkWindow->GZZMouseY)/8+1;
  445. if (cx >= MINWIDTH && cx <= MAXWIDTH && cy >= MINHEIGHT && cy <= maxheight) {
  446.     jx = (cx-1)*8-2;
  447.     jy = (cy-1)*8+FirstWorkWindow.TopEdge;
  448.     MoveSprite(&WorkScreen->ViewPort,&Cursor,jx,jy);
  449. }
  450.  
  451. if (message = (struct IntuiMessage *)GetMsg(WorkWindow->UserPort)) {
  452.     MessageClass = message->Class;
  453.     code = message->Code;
  454.     qualifier = message->Qualifier;
  455.     ReplyMsg(message);
  456.     if (MessageClass & MOUSEBUTTONS) {
  457.         switch    (code) {
  458.             case SELECTDOWN: mbuttons = TRUE;
  459.                      break;
  460.                                        
  461.             case  SELECTUP: mbuttons = FALSE;
  462.                     break;
  463.             }
  464.         }
  465.     else switch (MessageClass) {
  466.         case RAWKEY: if (!(code & IECODE_UP_PREFIX)) {
  467.                  inputEvent.ie_Code = code;
  468.                  inputEvent.ie_Qualifier = qualifier;
  469.                  scanner = RawKeyConvert(&inputEvent,Buffer,MAXINPUTLEN,0);
  470.                  Buffer[scanner] = 0;
  471.                  if (Buffer[0]==0x9b && scanner>1) {
  472.                 switch (Buffer[1]) {
  473.                     case CURSOR_UP: cy--;
  474.                             if (cy < MINHEIGHT) cy = MINHEIGHT;
  475.                             break;
  476.             
  477.                     case CURSOR_DOWN: cy++;
  478.                               if (cy > maxheight) cy = maxheight;
  479.                               break;
  480.             
  481.                     case CURSOR_LEFT: if (qualifier & IEQUALIFIER_CONTROL) {
  482.                                   if (middle != 0 && middle != &storage) {
  483.                                     back = middle;
  484.                                     tempnum = 1;
  485.                                     while (back != 0 && back != &storage && tempnum == 1) {
  486.                                         back=back->previous;
  487.                                             if (middle->x == back->x && middle->y == back->y) {
  488.                                             memusestr[0]=back->letter;
  489.                                             memusestr[1]=0;
  490.                                             ColorTextXY(WorkWindow,memusestr,back->x,back->y,back->fcolor,back->bcolor);
  491.                                             tempnum = 0;
  492.                                             }
  493.                                         }
  494.                                     if (back==0 || back==&storage) {
  495.                                         memusestr[0] = SPACE;
  496.                                         memusestr[1] = 0;
  497.                                         ColorTextXY(WorkWindow,memusestr,middle->x,middle->y,1,0);
  498.                                         }
  499.                                     middle=middle->previous;
  500.                                     if (middle != &storage) {
  501.                                         cx = middle->x;
  502.                                         cy = middle->y;
  503.                                         }
  504.                                     else {
  505.                                         cx = MINWIDTH;
  506.                                         cy = MINHEIGHT;
  507.                                         } 
  508.                                     --position;
  509.                                     }
  510.                                 } 
  511.                             else {
  512.                                 cx--;
  513.                                 if (cx < MINWIDTH) cx = MINWIDTH;
  514.                                 }
  515.                             break;
  516.                 
  517.                             case CURSOR_RIGHT: if (qualifier & IEQUALIFIER_CONTROL) {
  518.                                         if (middle != 0) {
  519.                                             if (middle->next != 0) {
  520.                                                 middle=middle->next;
  521.                                                 cx = middle->x; cy = middle->y;
  522.                                                 ++position;
  523.                                                 }
  524.                                             memusestr[0]=middle->letter;
  525.                                             memusestr[1]=0;
  526.                                             ColorTextXY(WorkWindow,memusestr,middle->x,middle->y,middle->fcolor,middle->bcolor);
  527.                                             }
  528.                                         } 
  529.                                        else {
  530.                                         cx++;
  531.                                         if (cx > MAXWIDTH) cx = MAXWIDTH;
  532.                                         }
  533.                                        break;
  534.                 
  535.                             default: if (scanner == 3 && Buffer[2] == '~') {
  536.                                     if (Buffer[1] == '?') {
  537.                                         if (gadwinfront) {
  538.                                             WindowToBack(Gads);
  539.                                             gadwinfront = FALSE;
  540.                                             }
  541.                                         else {
  542.                                             WindowToFront(Gads);
  543.                                             gadwinfront = TRUE;
  544.                                             }
  545.                                     break;
  546.                                     }
  547.                                  Buffer[2] = 0;
  548.                                  tempnum = atoi(&Buffer[1]);
  549.                                  Buffer[2] = '~';
  550.                                  if (tempnum >= 0 && tempnum <= 7) {
  551.                                     Buffer[0] = funckey[presset][tempnum];
  552.                                     Buffer[1] = 0;
  553.                                     scanner = 1;
  554.                                     }
  555.                                  if (tempnum == 8) {
  556.                                     ++presset;
  557.                                     if (presset > MAXCHARSETS-1) presset = 0;
  558.                                     }
  559.                                  if (tempnum == 9) {
  560.                                     --presset;
  561.                                     if (presset < 0) presset = MAXCHARSETS-1;
  562.                                     }
  563.                                  }
  564.                             }
  565.                         }
  566.                     if (scanner > 0 && Buffer[0] != 0x9b) {
  567.                         switch (Buffer[0]) {
  568.                             case RETURN: cx = MINWIDTH;
  569.                                      cy++;
  570.                                      if (cy > maxheight) cy = maxheight;
  571.                                      break;
  572.                                 
  573.                             case BACKSPACE: if (lastptr == &storage || middle == &storage) break;
  574.                                     back = middle;
  575.                                     tempnum = 1;
  576.                                     while (back != 0 && back != &storage && tempnum == 1) {
  577.                                         back=back->previous;
  578.                                         if (middle->x == back->x && middle->y == back->y) {
  579.                                             memusestr[0]=back->letter;
  580.                                             memusestr[1]=0;
  581.                                             ColorTextXY(WorkWindow,memusestr,back->x,back->y,back->fcolor,back->bcolor);
  582.                                             tempnum = 0;
  583.                                             }
  584.                                         }
  585.                                     if (back==0 || back==&storage) {
  586.                                         memusestr[0] = SPACE;
  587.                                         memusestr[1] = 0;
  588.                                         ColorTextXY(WorkWindow,memusestr,middle->x,middle->y,1,0);
  589.                                         }
  590.                                     if (middle->next == 0) {
  591.                                         free((UBYTE *)lastptr);
  592.                                         lastptr = sdlstptr;
  593.                                         sdlstptr = sdlstptr->previous;
  594.                                         lastptr->next = 0;
  595.                                         memusestr[0] = lastptr->letter;
  596.                                         memusestr[1] = 0;
  597.                                         if (lastptr != &storage) {
  598.                                             ColorTextXY(WorkWindow,memusestr,lastptr->x,lastptr->y,lastptr->fcolor,lastptr->bcolor);
  599.                                             cx = lastptr->x; cy = lastptr->y;
  600.                                             }
  601.                                         middle = lastptr;
  602.                                         }
  603.                                     else {
  604.                                         for (back = middle, front = back->next; front != 0; back=back->next, front = back->next) {
  605.                                             back->fcolor = front->fcolor;
  606.                                             back->bcolor = front->bcolor;
  607.                                             back->x = front->x;
  608.                                             back->y = front->y;
  609.                                             back->letter = front->letter;
  610.                                             }
  611.                                         free((UBYTE *)lastptr);
  612.                                         lastptr = sdlstptr;
  613.                                         sdlstptr = sdlstptr->previous;
  614.                                         lastptr->next = 0;
  615.                                         middle = middle->previous;
  616.                                         memusestr[0] = middle->letter;
  617.                                         memusestr[1] = 0;
  618.                                         if (middle != &storage) {
  619.                                             ColorTextXY(WorkWindow,memusestr,middle->x,middle->y,middle->fcolor,middle->bcolor);
  620.                                             cx = middle->x; cy = middle->y;
  621.                                             }
  622.                                         }
  623.                                     position--; length--; changes = TRUE;
  624.                                     break;
  625.                                     
  626.                             case TAB: tabplace = cx;
  627.                                   tabplace += (tabspace - ((cx-1) % tabspace));
  628.                                   if (tabplace > MAXWIDTH) {
  629.                                     tabplace = MINWIDTH;
  630.                                     cy++;
  631.                                     if (cy > maxheight) cy = maxheight;
  632.                                     }
  633.                                   cx = tabplace;
  634.                                   break;
  635.                                                     
  636.                             default: for (tempnum = 0; tempnum < scanner; tempnum++) {
  637.                                     if (Buffer[tempnum] < 32 || Buffer[tempnum] == 127) break;
  638.                                     sdlstptr = lastptr;
  639.                                     lastptr = (struct ANSI *) malloc(sizeof(struct ANSI));
  640.                                     if (lastptr == 0) {
  641.                                         lastptr = sdlstptr;
  642.                                         sdlstptr = lastptr->previous;
  643.                                         break;
  644.                                         }
  645.                                     sdlstptr->next = lastptr;
  646.                                     lastptr->previous = sdlstptr;
  647.                                     lastptr->next = 0;
  648.                                     if (middle->next == lastptr) {
  649.                                         lastptr->letter = Buffer[tempnum];
  650.                                         lastptr->x = cx;
  651.                                         lastptr->y = cy;
  652.                                         lastptr->fcolor = fcolor;
  653.                                         lastptr->bcolor = bcolor;
  654.                                         middle = lastptr;
  655.                                         } 
  656.                                     else {
  657.                                     middle = middle->next;
  658.                                     for (back = lastptr, front = back->previous; back != middle; back = back->previous, front = back->previous) {
  659.                                         back->fcolor = front->fcolor;
  660.                                         back->bcolor = front->bcolor;
  661.                                         back->x = front->x;
  662.                                         back->y = front->y;
  663.                                         back->letter = front->letter;
  664.                                         }
  665.                                     middle->letter = Buffer[tempnum];
  666.                                     middle->x = cx;
  667.                                     middle->y = cy;
  668.                                     middle->fcolor = fcolor;
  669.                                     middle->bcolor = bcolor;
  670.                                     }
  671.                                 ColorTextXY(WorkWindow,Buffer,cx,cy,fcolor,bcolor);
  672.                                 cx++;
  673.                                 if (cx > MAXWIDTH) {
  674.                                     cx = MINWIDTH; cy++;
  675.                                     if (cy > maxheight) cy=maxheight;
  676.                                     }
  677.                                 position++; length++;
  678.                                 changes = TRUE;
  679.                                 }
  680.                             break;
  681.                         }
  682.                     }
  683.                 }
  684.             break;
  685.  
  686.         case MENUPICK: MenuAnalyse(code);
  687.                    break;
  688.         }
  689.     } 
  690. else {
  691.     sprintf(memusestr,"P:X=%2d Y=%2d",mx,my);
  692.     if (mx < 1 || my < 1) sprintf(memusestr,"P:         ");
  693.     ColorText(Gads,memusestr,488,1,7,0);
  694.     sprintf(memusestr,"C:X=%2d Y=%2d",cx,cy);
  695.     ColorText(Gads,memusestr,380,1,7,0);
  696.     sprintf(memusestr,"Pos: %5d  Len: %5d",position,length);
  697.     ColorText(Gads,memusestr,2,1,7,0);
  698.     sprintf(memusestr,"ForeC: %2d  BackC: %2d",fcolor,bcolor);
  699.     ColorText(Gads,memusestr,200,1,fcolor,bcolor);
  700.     sprintf(memusestr,"Set:%2d F1=%c F2=%c F3=%c F4=%c F5=%c F6=%c F7=%c F8=%c",presset+1,funckey[presset][0],funckey[presset][1],
  701.         funckey[presset][2],funckey[presset][3],funckey[presset][4],funckey[presset][5],
  702.         funckey[presset][6],funckey[presset][7]);
  703.     ColorText(Gads,memusestr,3,20,7,0);
  704.     sprintf(memusestr,"Free Memory:%7d",AvailMem(0));
  705.     ColorText(Gads,memusestr,390,20,3,0);
  706.     }
  707.     if (message = (struct IntuiMessage *) GetMsg(Gads->UserPort)) {
  708.         MessageClass = message->Class;
  709.         GadgetPtr = (struct Gadget *) message->IAddress;
  710.         ReplyMsg(message);
  711.         GadgetID = GadgetPtr->GadgetID;
  712.         switch    (MessageClass) {
  713.                 case GADGETUP:  if (GadgetID == 18) {
  714.                     BGmode=togglemode();
  715.                     break;
  716.                     }
  717.                 if (GadgetID == 17) {
  718.                     if (cmode==0) BGmode = TRUE; else BGmode=FALSE;
  719.                     break;
  720.                     }
  721.                 if (BGmode == TRUE) {
  722.                     if (GadgetID >= 1 && GadgetID <=8) {
  723.                         bcolor = (USHORT)GadgetID-1;
  724.                         if (cmode==0) BGmode = FALSE;
  725.                         }
  726.                     }
  727.                 else {
  728.                     if (GadgetID >= 1 && GadgetID <= 16)
  729.                         fcolor = (USHORT)GadgetID - 1;
  730.                     if (cmode==1) BGmode=TRUE;
  731.                     }
  732.                 break;
  733.                     
  734.         case ACTIVEWINDOW: ActivateWindow(WorkWindow);
  735.                    break;
  736.  
  737.         default: break;
  738.         }
  739.     ActivateWindow(WorkWindow);
  740.         }
  741. if (mbuttons) {
  742. /**** Move the cursor to (mx,my) ****/;
  743.     cx = mx;
  744.     cy = my;
  745.     if (cx < MINWIDTH) cx = MINWIDTH;
  746.     if (cx > MAXWIDTH) cx = MAXWIDTH;
  747.     if (cy < MINHEIGHT) cy = MINHEIGHT;
  748.     if (cy > maxheight) cy = maxheight;
  749.         }
  750.     }
  751. }
  752.  
  753. /* Routine to toggle fore/back mode ... new to 1.4 by Syd L. Bolton */
  754. togglemode()
  755. {
  756. cmode=1-cmode;
  757. if (cmode==0) {
  758.     ForeBackText.IText="Back";
  759.     FBStickText.IText="Fore";
  760.     }
  761. else {
  762.     ForeBackText.IText="Fore";
  763.     FBStickText.IText="Back";
  764.     }
  765. SetAPen(rport,0);
  766. RectFill(rport,553,10,635,28);
  767. RefreshGadgets(&FBStickGadget,Gads,0);
  768. if (cmode==0) return(FALSE); else return(TRUE);
  769. }
  770.     
  771. #include "config.c"
  772.  
  773. /************************************************************************
  774. *                Now, for the Libraries that need to be opened            *
  775. ************************************************************************/
  776. OpenLibs()
  777. {
  778. DOSBase = (struct DOSBase *) OpenLibrary("dos.library",0L);
  779. IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0L);
  780. GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 0L);
  781.  
  782. if ((DiskfontBase = (struct DiskfontBase *) OpenLibrary("diskfont.library",0))==0) {
  783.     CloseLibs("Diskfont Library cannot be found");
  784.     exit(FALSE);
  785.     }
  786. if ((TFont = (struct TextFont *) OpenDiskFont(&WorkFont)) == 0) {
  787.     WorkFont.ta_Name = (STRPTR)"topaz.font";
  788.     WorkFont.ta_YSize = TOPAZ_EIGHTY;
  789.     }
  790. Cursor.x = -1;
  791. Cursor.y = 10;
  792. Cursor.height = 8;
  793. Spr1 = GetSprite(&Cursor,-1);
  794. if (Spr1 == -1) {
  795.     CloseLibs("Sprite cannot be displayed");
  796.     exit(FALSE);
  797.     }
  798.  
  799. OpenSAW();
  800.     
  801. if (!(OpenDevice("console.device",-1L,&ioStdReq,0L))) ConsoleDevice = ioStdReq.io_Device;
  802. else CloseLibs("Could not open console.device");
  803. }
  804.  
  805. OpenSAW()
  806. {
  807. struct ViewPort *vp;
  808.  
  809. if (!(WorkScreen = (struct Screen *) OpenScreen(&FirstWorkScreen))) {
  810.     CloseLibs("Screen cannot be opened");
  811.     exit(FALSE);
  812.     }
  813. vp = &WorkScreen->ViewPort;
  814. SetWindowSprite();
  815. LoadRGB4(vp,AtrColors,16);
  816. RemakeDisplay();
  817. FirstWorkWindow.Screen = WorkScreen;
  818. if (!(WorkWindow = (struct Window *) OpenWindow(&FirstWorkWindow))) {
  819.     CloseLibs("Window cannot be opened");
  820.     exit(FALSE);
  821.     }
  822. GadgetWindow.Screen = WorkScreen;
  823. if (!(Gads = (struct Window *) OpenWindow(&GadgetWindow))) {
  824.     CloseLibs("Gadget window cannot be opened");
  825.     exit(FALSE);
  826.     }
  827. rport=Gads->RPort;
  828. if (sclearmode) SClear.Flags |= CHECKED; else Clear.Flags &= ~CHECKED;
  829. if (lacemode) Interlace.Flags |= CHECKED; else Interlace.Flags &= ~CHECKED;
  830. SetMenuStrip(WorkWindow, &Project);
  831. return(0);
  832. }
  833.  
  834. /************************************************************************
  835. *       If Libraries have to be opened, then they have to be closed!    *
  836. ************************************************************************/
  837. CloseLibs(str)
  838. UBYTE *str;
  839. {
  840. USHORT handle;
  841.     
  842. FreeAllMem();
  843. if(Spr1 != -1) FreeSprite(Spr1);
  844. CloseSAW();
  845. if(TFont) CloseFont(TFont);
  846. if(DiskfontBase) CloseLibrary(DiskfontBase);
  847. CloseLibrary(GfxBase);
  848. CloseLibrary(IntuitionBase);
  849. CloseLibrary(DOSBase);
  850. if(str[0] != '~') {
  851.         handle = Open("RAW:160/50/320/25/Prism",MODE_NEWFILE);
  852.         if (handle) {
  853.         Write(handle,str,strlen(str));
  854.         Delay(120L);
  855.         Close(handle);
  856.             }
  857.        }
  858. }
  859.  
  860. CloseSAW()
  861. {
  862. if (Gads) CloseWindow(Gads);
  863. if (WorkWindow) {
  864.     ClearMenuStrip(WorkWindow);
  865.     CloseWindow(WorkWindow);
  866.     }
  867. if (WorkScreen) CloseScreen(WorkScreen);
  868. return(0);
  869. }
  870.  
  871. /*************************************************************************
  872. *                  The color version of the Text routine                *
  873. *************************************************************************/
  874. ColorText(w_ptr,s,x,y,fc,bc)
  875. struct Window *w_ptr;
  876. UBYTE *s;
  877. USHORT x,y;
  878. USHORT fc,bc;
  879. {
  880. GeneralText.FrontPen = (UBYTE) fc;
  881. GeneralText.BackPen = (UBYTE) bc;
  882. GeneralText.IText = (UBYTE *) s;
  883. PrintIText(w_ptr->RPort,&GeneralText,x,y);
  884. return(TRUE);
  885. }
  886.  
  887. /*************************************************************************
  888. *      X and Y now represent the row and column of TEXT and not bits     *
  889. *************************************************************************/
  890. ColorTextXY(w_ptr,s,x,y,fc,bc)
  891. struct Window *w_ptr;
  892. UBYTE *s;
  893. USHORT x,y;
  894. USHORT fc,bc;
  895. {
  896. USHORT ix,iy;
  897.     
  898. GeneralText.FrontPen = (UBYTE) fc;
  899. GeneralText.BackPen = (UBYTE) bc;
  900. GeneralText.IText = (UBYTE *) s;
  901.  
  902. if (x < MINWIDTH || x > MAXWIDTH || y < MINHEIGHT || y > maxheight) return(FALSE);
  903. ix = (x-1)*8; /* to calculate distance by text size and not pixels */
  904. iy = (y-1)*8;
  905.     
  906. PrintIText(w_ptr->RPort,&GeneralText,ix,iy);
  907. return(TRUE);
  908. }
  909.  
  910. /*************************************************************************
  911. *                         Free the used memory                           *
  912. *************************************************************************/
  913. FreeAllMem()
  914. {
  915. struct IntuiText ClearingText = {
  916.     4,7,JAM2,126,11,0,"Clearing Current ANSI.  Please Wait.",0
  917.     };
  918.     
  919. InitRequester(&FileSelectBox);
  920. FileSelectBox.LeftEdge = 50;
  921. FileSelectBox.TopEdge = 85;
  922. FileSelectBox.Width = 540;
  923. FileSelectBox.Height = 30;
  924. FileSelectBox.ReqText = &ClearingText;
  925. FileSelectBox.BackFill = 7;
  926. Request(&FileSelectBox, WorkWindow);
  927. for (lastptr=storage.next; lastptr != 0; lastptr = lastptr->next)
  928.         free((UBYTE *)lastptr);
  929. storage.next = 0;
  930. lastptr = &storage;
  931. middle = lastptr;
  932. length = 0; position = 0;
  933. cx = MINWIDTH; cy = MINHEIGHT; changes = FALSE;
  934. EndRequest(&FileSelectBox, WorkWindow);
  935. return(TRUE);
  936. }
  937.  
  938. /*************************************************************************
  939. *               Attempt to playback what what stored in Memory           *
  940. *************************************************************************/
  941. PlayBack()
  942. {
  943. UBYTE displaystr[2];
  944.     
  945. position = length = 0;
  946. ClearWorkWindow();
  947. WindowToFront(WorkWindow);
  948. ChangeSprite(&WorkScreen->ViewPort,&Cursor,ChipBlank);
  949. Delay(30L);
  950. displaystr[1] = 0;
  951. if (speed==0) {
  952.     for (lastptr=storage.next; lastptr != 0; lastptr = lastptr->next) {
  953.         displaystr[0] = lastptr->letter;
  954.         ColorTextXY(WorkWindow,displaystr,lastptr->x,lastptr->y, lastptr->fcolor,lastptr->bcolor);
  955.         ++position;++length;
  956.         }
  957.     }
  958. else {
  959.     for (lastptr=storage.next; lastptr != 0; lastptr = lastptr->next) {
  960.         displaystr[0] = lastptr->letter;
  961.         ColorTextXY(WorkWindow,displaystr,lastptr->x,lastptr->y, lastptr->fcolor,lastptr->bcolor);
  962.         ++position;++length;
  963.         Delay(speed);
  964.         }
  965.     }
  966. lastptr = sdlstptr->next;
  967. middle = lastptr;
  968. cx = middle->x; cy = middle->y;
  969. SetWindowSprite();
  970. WindowToBack(WorkWindow);
  971. return(TRUE);
  972. }
  973.  
  974. /*************************************************************************
  975. *                        Clear the WorkWindow                            *
  976. *************************************************************************/
  977. ClearWorkWindow()
  978. {
  979. USHORT i;
  980. static UBYTE blanker[] = "                                                                                ";
  981.     
  982. for (i=0; i<=FirstWorkWindow.Height; i+=8)
  983.     ColorText(WorkWindow,blanker,0,i,1,0);
  984. return(TRUE);
  985. }
  986.  
  987. /************************************************************************
  988. *               Analyse which item was picked on the menu               *
  989. ************************************************************************/
  990. MenuAnalyse(Menunumber)
  991. USHORT Menunumber;
  992. {
  993. USHORT Menu, MenuItem, SubItem;
  994.     
  995. Menu = MENUNUM(Menunumber);
  996. MenuItem = ITEMNUM(Menunumber);
  997. SubItem = SUBNUM(Menunumber);
  998.  
  999. switch (Menu) {
  1000.         case 0: ProjectMenu(MenuItem,SubItem);
  1001.         break;
  1002.         
  1003.     case 1:    SetupMenu(MenuItem,SubItem);
  1004.         break;
  1005.  
  1006.     default: break;
  1007.     }
  1008. return(TRUE);
  1009. }
  1010.  
  1011. ProjectMenu(MenuItem,SubItem)
  1012. USHORT MenuItem, SubItem;
  1013. {
  1014. BOOL GetResponse;
  1015.     
  1016. switch (MenuItem) {
  1017.         case 0: AboutReq();
  1018.         break;
  1019.             
  1020.         case 1: PlayBack();
  1021.         break;
  1022.             
  1023.         case 2: GetResponse = AreYouSure("Clear Memory?");
  1024.         if (GetResponse == TRUE) {
  1025.             if (changes == TRUE) {
  1026.             GetResponse = AreYouSure("Save new changes?");
  1027.             if (GetResponse == TRUE) SaveANSI(TRUE);
  1028.             }
  1029.         FreeAllMem();
  1030.         ClearWorkWindow();
  1031.         }
  1032.         break;
  1033.  
  1034.         case 3: LoadANSI(TRUE);
  1035.         break;
  1036.         
  1037.     case 4: SaveANSI(TRUE);
  1038.         break;
  1039.         
  1040.     case 5: switch(SubItem) {    /* APPEND SUBMENUS */
  1041.             case 0:    LoadANSI(FALSE);
  1042.                 break;
  1043.             case 1:    SaveANSI(FALSE);
  1044.                     break;
  1045.             }
  1046.         break;
  1047.  
  1048.     case 6: GetResponse = AreYouSure("Exit Prism?");
  1049.         if (GetResponse == TRUE) {
  1050.             if (changes == TRUE) {
  1051.                 GetResponse = AreYouSure("Save new changes?");
  1052.                 if (GetResponse == TRUE) SaveANSI(TRUE);
  1053.                 }
  1054.         CloseLibs("~");
  1055.         exit(TRUE);
  1056.         }
  1057.         break;
  1058.     }
  1059. return(TRUE);
  1060. }
  1061.  
  1062. SetupMenu(MenuItem,SubItem)
  1063. USHORT MenuItem,SubItem;
  1064. {
  1065. switch (MenuItem) {
  1066.     case 0:    SelColor3.NextGadget = &SelColor4;
  1067.         SelColor7.NextGadget = &SelColor8;
  1068.         switch (SubItem) {
  1069.             case 0: CloseSAW();
  1070.                 FirstWorkScreen.Depth = 2;
  1071.                 SelColor3.NextGadget = &FBStickGadget;
  1072.                 OpenSAW();
  1073.                 break;
  1074.             
  1075.             case 1:    CloseSAW();
  1076.                 FirstWorkScreen.Depth = 3;
  1077.                 SelColor7.NextGadget = &FBStickGadget;
  1078.                 OpenSAW();
  1079.                 break;
  1080.             
  1081.             case 2:    CloseSAW();
  1082.                 FirstWorkScreen.Depth = 4;
  1083.                 OpenSAW();
  1084.                 break;
  1085.  
  1086.             default: break;
  1087.             }
  1088.             break;
  1089.  
  1090.     case 1: set_speed(SubItem);
  1091.         break;
  1092.  
  1093.     case 2: CloseSAW();
  1094.         if (FirstWorkScreen.Height==210) {
  1095.             FirstWorkScreen.Height=420;
  1096.             FirstWorkScreen.ViewModes=HIRES|SPRITES|LACE;
  1097.             FirstWorkWindow.Height=400;
  1098.             maxheight=50;
  1099.             lacemode=1;
  1100.             }
  1101.         else {
  1102.             FirstWorkScreen.Height=210;
  1103.             FirstWorkScreen.ViewModes=HIRES|SPRITES;
  1104.             FirstWorkWindow.Height=200;
  1105.             maxheight=25;
  1106.             lacemode=0;
  1107.             }
  1108.         OpenSAW();
  1109.         break;
  1110.  
  1111.     case 3: sclearmode=1-sclearmode;
  1112.         if (sclearmode) SClear.Flags |= CHECKED;
  1113.         else SClear.Flags &= ~CHECKED;
  1114.         break;
  1115.  
  1116.     case 4: configure();
  1117.         break;
  1118.  
  1119.     default: break;
  1120.     }
  1121. return(TRUE);
  1122. }
  1123.  
  1124. set_speed(sub)
  1125. int sub;
  1126. {
  1127. switch (sub) {
  1128.     case 0: TWBaud.Flags |= CHECKED;
  1129.         TFBaud.Flags &= ~CHECKED;
  1130.         Fastest.Flags &= ~CHECKED;
  1131.         speed=2;
  1132.         break;
  1133.  
  1134.     case 1: TFBaud.Flags |= CHECKED;
  1135.         TWBaud.Flags &= ~CHECKED;
  1136.         Fastest.Flags &= ~CHECKED;
  1137.         speed=1;
  1138.         break;
  1139.  
  1140.     case 2: Fastest.Flags |= CHECKED;
  1141.         TFBaud.Flags &= ~CHECKED;
  1142.         TWBaud.Flags &= ~CHECKED;
  1143.         speed=0;
  1144.         break;
  1145.  
  1146.     default: break;
  1147.     }
  1148. }
  1149.  
  1150. /************************************************************************
  1151. *                     An "Are You Sure?" Requester                      *
  1152. ************************************************************************/
  1153. AreYouSure(yousaidit)
  1154. UBYTE *yousaidit;
  1155. {
  1156. BOOL Response;
  1157.     
  1158. struct IntuiText Really = {
  1159.     0,1,JAM1,40,5,0,0,0
  1160.     };
  1161. struct IntuiText Yes = {
  1162.     0,1,JAM1,5,3,0,"YES",0
  1163.     };
  1164. struct IntuiText No = {
  1165.     0,1,JAM1,5,3,0,"NO!",0
  1166.     };
  1167.  
  1168. Really.IText = (UBYTE *)yousaidit;
  1169. Response = AutoRequest(WorkWindow,&Really,&Yes,&No,0,0,TextLength(WorkWindow->RPort,yousaidit,strlen(yousaidit))+100,50);
  1170. return((USHORT)Response);
  1171. }
  1172.  
  1173. /*************************************************************************
  1174. *              The "Something Went Wrong" Requester Routine              *
  1175. *************************************************************************/
  1176. GenErrorReq(thecatch)
  1177. UBYTE *thecatch;
  1178. {
  1179. BOOL Answer;
  1180. struct IntuiText SomethingText = {
  1181.     0,1,JAM2,15,8,0,0,0
  1182.     };
  1183. struct IntuiText AlrightText = {
  1184.     0,1,JAM2,5,3,0,"OK?",0
  1185.     };
  1186. SomethingText.IText = (UBYTE *)thecatch;
  1187. Answer = AutoRequest(WorkWindow,&SomethingText,0,&AlrightText,0,0,TextLength(WorkWindow->RPort,thecatch,strlen(thecatch))+100,37);
  1188. return((USHORT)Answer);
  1189. }
  1190.  
  1191. /*************************************************************************
  1192. *                     The "About" Requester Routine                      *
  1193. *************************************************************************/
  1194. AboutReq()
  1195. {
  1196. BOOL Waiting;
  1197. UBYTE *LeftMouse = (UBYTE *)0xBFE001;
  1198.  
  1199. ChangeSprite(&WorkScreen->ViewPort,&Cursor,ChipBlank);
  1200. RequesterWindow.LeftEdge = 41;
  1201. RequesterWindow.TopEdge = 20;
  1202. RequesterWindow.Width = 558;
  1203. RequesterWindow.Height = 82;
  1204. RequesterWindow.Title = 0;
  1205. RequesterWindow.Screen = WorkScreen;
  1206. RequesterWindow.FirstGadget = 0;
  1207. InitRequester(&FileSelectBox);
  1208. FileSelectBox.LeftEdge = 4;
  1209. FileSelectBox.TopEdge = 2;
  1210. FileSelectBox.Width = 550;
  1211. FileSelectBox.Height = 90;
  1212. FileSelectBox.ReqText = &AboutProgText;
  1213. FileSelectBox.BackFill = 7;
  1214. if (!(ReqWindow = (struct Window *) OpenWindow(&RequesterWindow))) {
  1215.     SetWindowSprite();
  1216.     return(FALSE);
  1217.     }
  1218. Request(&FileSelectBox, ReqWindow);
  1219. Waiting = TRUE;
  1220. while (Waiting)
  1221.     if(!((*LeftMouse & 0x40) == 0x40)) Waiting = FALSE;
  1222. EndRequest(&FileSelectBox, ReqWindow);
  1223. if (ReqWindow)  CloseWindow(ReqWindow);
  1224. SetWindowSprite();
  1225. return((USHORT)FALSE);
  1226. }
  1227.  
  1228. /************************************************************************
  1229. *               Load ANSI from Disk                *
  1230. *             New improved Routine by Chris                   *
  1231. ************************************************************************/
  1232.  
  1233. LoadANSI(loadtype)
  1234. BOOL loadtype;
  1235. {
  1236. BOOL Answer;
  1237. FILE *AnsiFile;
  1238. UBYTE c;
  1239. UWORD cx = 1, cy = 1;
  1240. UWORD *t, *z;
  1241. UWORD Col1 = 1, Col2 = 0, Inten=0, flag, sx, sy, a[3];
  1242. struct IntuiText LoadingText = {
  1243.     4,7,JAM2,122,11,0,"Loading ANSI from disk.  Please Wait.",0
  1244.     };
  1245. ChangeSprite(&WorkScreen->ViewPort,&Cursor,ChipBlank);
  1246. if (loadtype == TRUE) Answer = getfile("Load ANSI",path);
  1247. else Answer = getfile("Append Load",path);
  1248. if (Answer == FALSE) {
  1249.     SetWindowSprite();
  1250.     return(FALSE);
  1251.     }
  1252.  
  1253. if (!(AnsiFile = fopen(filename,"r"))) {
  1254.     GenErrorReq("File can't open for read!");
  1255.     SetWindowSprite();
  1256.     return(FALSE);
  1257.     }
  1258. SetPointer(WorkWindow,&BusyPointer,22,16,0,0);
  1259. /***** Start Loading *****/
  1260. if (loadtype == TRUE) {
  1261.     FreeAllMem();
  1262.     ClearWorkWindow();
  1263.     }
  1264. InitRequester(&FileSelectBox);
  1265. FileSelectBox.LeftEdge = 50;
  1266. FileSelectBox.TopEdge = 85;
  1267. FileSelectBox.Width = 540;
  1268. FileSelectBox.Height = 30;
  1269. FileSelectBox.ReqText = &LoadingText;
  1270. FileSelectBox.BackFill = 7;
  1271. Request(&FileSelectBox, WorkWindow);
  1272. while (!(feof(AnsiFile))) {
  1273.     c=getc(AnsiFile);
  1274.     switch(c) {
  1275.         case ESC: t=a; flag=0; a[0]=0; a[1]=0; a[2]=0;
  1276.               if (getc(AnsiFile)!='[') break;
  1277.               do {
  1278.                 c=getc(AnsiFile);
  1279.                 switch (c) {
  1280.                     case ';': t++; break;
  1281.  
  1282.                     case 'm': for (z=a; z<=t; z++) {
  1283.                                     if      (*z==0) { Col1=7; Col2=0; Inten=0; }
  1284.                             else if (*z==1)                   Inten=8;
  1285.                             else if (*z>29 && *z<40)          Col1=*z-30;
  1286.                             else if (*z>39 && *z<50)          Col2=*z-40;
  1287.                             }
  1288.                           flag=1;
  1289.                           break;
  1290.  
  1291.                     case 'H': cy=a[0]; if (cy==0) cy=1; else if (cy>maxheight) cy=maxheight;
  1292.                           cx=a[1]; if (cx==0) cx=1; else if (cx>MAXWIDTH)  cx=MAXWIDTH;
  1293.                           flag=1;
  1294.                           break;
  1295.  
  1296.                     case 'J': cx=MINWIDTH; cy=MINHEIGHT; flag=1;
  1297.                           break;
  1298.  
  1299.                     case 's': sx=cx; sy=cy; flag=1;
  1300.                           break;
  1301.  
  1302.                     case 'u': cx=sx; cy=sy; flag=1;
  1303.                           break;
  1304.  
  1305.                     case 'A': if (a[0]==0) a[0]=1;
  1306.                           cy-=a[0]; if (cy<MINHEIGHT) cy=MINHEIGHT;
  1307.                           flag=1;
  1308.                           break;
  1309.  
  1310.                     case 'D': if (a[0]==0) a[0]=1;
  1311.                           cx-=a[0]; if (cx<MINWIDTH) cx=MINWIDTH;
  1312.                           flag=1;
  1313.                           break;
  1314.  
  1315.                     case 'C': if (a[0]==0) a[0]=1;
  1316.                           cx+=a[0]; if (cx>MAXWIDTH) cx=MAXWIDTH;
  1317.                           flag=1;
  1318.                           break;
  1319.  
  1320.                     case 'B': if (a[0]==0) a[0]=1;
  1321.                           cy+=a[0]; if (cy>maxheight) cy=maxheight;
  1322.                           flag=1;
  1323.                           break;
  1324.  
  1325.                     default: *t=(*t << 3) + (*t << 1) + c - '0';
  1326.                     break;
  1327.                     }
  1328.                 } while (flag==0);
  1329.                 break;
  1330.  
  1331.         case  LINEFEED: cx = MINWIDTH;
  1332.                 cy++;
  1333.                 if (cy > maxheight) cy = maxheight;
  1334.                 break;
  1335.  
  1336.         default: if (c < 32 || c == 127) break;
  1337.              sdlstptr = lastptr;
  1338.              lastptr = (struct ANSI *) malloc(sizeof(struct ANSI));
  1339.              if (lastptr == 0) break;
  1340.              middle = lastptr;
  1341.              sdlstptr->next = lastptr;
  1342.              lastptr->previous = sdlstptr;
  1343.              lastptr->next = 0;
  1344.              lastptr->letter = c;
  1345.              lastptr->x = cx;
  1346.              lastptr->y = cy;
  1347.              lastptr->fcolor = Col1+Inten;
  1348.              lastptr->bcolor = Col2;
  1349.              if (++cx > MAXWIDTH) {
  1350.                 cx = MINWIDTH;
  1351.                 if (++cy > maxheight) cy=maxheight;
  1352.                 }
  1353.             break;
  1354.             }
  1355.         }
  1356. fclose(AnsiFile);
  1357. EndRequest(&FileSelectBox, WorkWindow);
  1358. ClearPointer(WorkWindow);
  1359. PlayBack();
  1360. SetWindowSprite();
  1361. return(TRUE);
  1362. }
  1363.  
  1364. /************************************************************************
  1365. *                           Save ANSI to disk                           *
  1366. *                   New improved routine by Chris                       *
  1367. ************************************************************************/
  1368. SaveANSI(savetype)
  1369. BOOL savetype;
  1370. {
  1371. BOOL Answer;
  1372. FILE *AnsiFile;
  1373. UBYTE Inten, Fore, Back, linelength, X, Y;
  1374. UBYTE OldInten=0, OldFore=7, OldBack=0, OldX=1, OldY=1;
  1375. UBYTE Line[41], savetypechr[2];
  1376.  
  1377. struct IntuiText SavingText = {
  1378.     4,7,JAM2,134,11,0,"Saving ANSI to disk.  Please Wait.",0
  1379.     };
  1380. ChangeSprite(&WorkScreen->ViewPort,&Cursor,ChipBlank);
  1381. if (savetype == TRUE) {
  1382.     savetypechr[0] = 'w';
  1383.     savetypechr[1] = 0;
  1384.     Answer = stdfile("Save ANSI",0,"#?",filename,WorkScreen);
  1385.     }
  1386. else {
  1387.     savetypechr[0] = 'a';
  1388.     savetypechr[1] = 0;
  1389.     Answer = stdfile("Append Save ANSI",0,"#?",filename,WorkScreen);
  1390.     }
  1391. if (Answer == FALSE) {
  1392.     SetWindowSprite();
  1393.     return(FALSE);
  1394. }
  1395. if (!(AnsiFile = fopen(filename,savetypechr))) {
  1396.     GenErrorReq("File can't open for write!");
  1397.     SetWindowSprite();
  1398.     return(FALSE);
  1399.     }
  1400. SetPointer(WorkWindow,&BusyPointer,22,16,0,0);
  1401. /***** Start Saving *****/
  1402. InitRequester(&FileSelectBox);
  1403. FileSelectBox.LeftEdge = 50;
  1404. FileSelectBox.TopEdge = 85;
  1405. FileSelectBox.Width = 540;
  1406. FileSelectBox.Height = 30;
  1407. FileSelectBox.ReqText = &SavingText;
  1408. FileSelectBox.BackFill = 7;
  1409. Request(&FileSelectBox, WorkWindow);
  1410. if (sclearmode) fprintf(AnsiFile,"%c[0m%c[H%c[J",ESC,ESC,ESC);
  1411. linelength = 10;
  1412. for (lastptr=storage.next; lastptr != 0; lastptr = lastptr->next) {
  1413.     Fore=lastptr->fcolor; Back=lastptr->bcolor; Inten=Fore&8; Fore&=7; X=lastptr->x; Y=lastptr->y;
  1414. /***** Check for color changes *****/
  1415.     if (Inten!=OldInten) {
  1416.         if (Inten==0) {
  1417.             if (Fore==7) {
  1418.                 if (Back==0) sprintf(Line, "%c[0m", ESC);
  1419.                 else sprintf(Line, "%c[0;4%dm", ESC, Back);
  1420.                 }
  1421.             else {
  1422.                 if (Back==0) sprintf(Line, "%c[0;3%dm", ESC, Fore);
  1423.                 else sprintf(Line, "%c[0;3%d;4%dm", ESC, Fore, Back);
  1424.                 }
  1425.             }
  1426.         else {
  1427.             if (Fore==OldFore) {
  1428.                 if (Back==OldBack) sprintf(Line, "%c[1m", ESC);
  1429.                 else sprintf(Line, "%c[1;4%dm", ESC, Back);
  1430.                 }
  1431.             else {
  1432.                 if (Back==OldBack) sprintf(Line, "%c[1;3%dm", ESC, Fore);
  1433.                 else {
  1434.                     if (Fore==7) sprintf(Line, "%c[0;1;4%dm", ESC, Back);
  1435.                     else if (Back==0) sprintf(Line, "%c[0;1;3%dm", ESC, Fore);
  1436.                     else sprintf(Line, "%c[1;3%d;4%dm", ESC, Fore, Back);
  1437.                     }
  1438.                 }
  1439.             }
  1440.         }
  1441.     else { /* no change in inten */
  1442.         if (Back!=OldBack) {
  1443.             if (Fore!=OldFore) sprintf(Line, "%c[3%d;4%dm", ESC, Fore, Back);
  1444.             else sprintf(Line, "%c[4%dm", ESC, Back);
  1445.             }
  1446.         else if (Fore!=OldFore) sprintf(Line, "%c[3%dm", ESC, Fore);
  1447.         else Line[0]=0;
  1448.         }
  1449.     if (Line[0]) {
  1450.         linelength += strlen(Line);
  1451.         if ((linelength+1) >= 80) {
  1452.             fprintf(AnsiFile,"%c[s%c%c[u",ESC,RETURN,ESC);
  1453.             linelength = 3 + strlen(Line);
  1454.             }
  1455.         fprintf(AnsiFile,"%s",Line);
  1456.         }
  1457. /***** Check for position changes *****/
  1458.     if (X!=OldX) {
  1459.         if (Y!=OldY) sprintf(Line, "%c[%d;%dH", ESC, Y, X);
  1460.         else {
  1461.         if (X==OldX+1) sprintf(Line, "%c[C", ESC);
  1462.         else if (X>OldX) sprintf(Line, "%c[%dC", ESC, X-OldX);
  1463.         else if (X==OldX-1) sprintf(Line, "%c[D", ESC);
  1464.         else if (X<OldX) sprintf(Line, "%c[%dD", ESC, OldX-X);
  1465.         }
  1466.     }
  1467. else {
  1468.     if (Y==OldY) Line[0]=0;
  1469.     else {
  1470.         if (Y==OldY+1) sprintf(Line, "%c[B", ESC);
  1471.         else if (Y>OldY) sprintf(Line, "%c[%dB", ESC, Y-OldY);
  1472.         else if (Y==OldY-1) sprintf(Line, "%c[A", ESC);
  1473.         else if (Y<OldY) sprintf(Line, "%c[%dA", ESC, OldY-Y);
  1474.         }
  1475.     }
  1476. if (Line[0]) {
  1477.     linelength += strlen(Line);
  1478.     if ((linelength+1) >= 80) {
  1479.         fprintf(AnsiFile,"%c[s%c%c[u",ESC,RETURN,ESC);
  1480.         linelength = 3 + strlen(Line);
  1481.         }
  1482.     fprintf(AnsiFile,"%s",Line);
  1483.     }
  1484. /***** Print the actual character *****/
  1485. if ((linelength+1) >= 80) {
  1486.     fprintf(AnsiFile,"%c[s%c%c[u",ESC,RETURN,ESC);
  1487.     linelength = 3;
  1488.     }
  1489. fprintf(AnsiFile,"%c",lastptr->letter);
  1490. linelength++;
  1491. if (++X>MAXWIDTH) {
  1492.     X=MINWIDTH;
  1493.     if (++Y > maxheight) Y=maxheight;
  1494.     }
  1495. OldInten=Inten; OldFore=Fore; OldBack=Back; OldX=X; OldY=Y;
  1496. }
  1497. lastptr = sdlstptr->next;
  1498. fclose(AnsiFile);
  1499. changes = FALSE;
  1500. EndRequest(&FileSelectBox, WorkWindow);
  1501. ClearPointer(WorkWindow);
  1502. SetWindowSprite();
  1503. return(TRUE);
  1504. }
  1505.  
  1506. SetWindowSprite()
  1507. {
  1508. if (FirstWorkWindow.Height==200) {
  1509.     Cursor.height=8;
  1510.     ChangeSprite(&WorkScreen->ViewPort,&Cursor,NormalCursor);
  1511.     }
  1512. else {
  1513.     Cursor.height=4;
  1514.     ChangeSprite(&WorkScreen->ViewPort,&Cursor,InterlaceCursor);
  1515.     }
  1516. }
  1517.  
  1518. getfile(titl,path)
  1519. char *titl,*path;
  1520. {
  1521. windowtopedge=WorkWindow->TopEdge;
  1522. windowleftedge=WorkWindow->LeftEdge;
  1523. while(stdfile(titl, filename, path, filename, WorkScreen)) {
  1524.     BPTR stdlock;
  1525.     struct FileInfoBlock *stdfib;
  1526.     FILE *fp;
  1527.     int c;
  1528.  
  1529.     stdfib = AllocMem(sizeof(struct FileInfoBlock), MEMF_PUBLIC);
  1530.     if (!stdfib) {
  1531.         GenErrorReq("Out of memory!\n");
  1532.         break;
  1533.         }
  1534.  
  1535.     if (!(stdlock = Lock(filename, ACCESS_READ))) {
  1536.         GenErrorReq("Can't obtain lock.");
  1537.         FreeMem(stdfib, sizeof(struct FileInfoBlock));
  1538.         continue;
  1539.         }
  1540.  
  1541.     if (!(Examine(stdlock, stdfib))) {
  1542.         GenErrorReq("Can't examine file");
  1543.         UnLock(stdlock);
  1544.         FreeMem(stdfib, sizeof(struct FileInfoBlock));
  1545.         continue;
  1546.         }
  1547.  
  1548.     UnLock(stdlock);
  1549.  
  1550.     if(stdfib->fib_DirEntryType >= 0) {
  1551.         GenErrorReq("That is a directory!");
  1552.         FreeMem(stdfib, sizeof(struct FileInfoBlock));
  1553.         continue;
  1554.         }
  1555.     FreeMem(stdfib, sizeof(struct FileInfoBlock));
  1556.     fclose(fp);
  1557.     return(TRUE);
  1558.     break;
  1559.     }
  1560. return(FALSE);
  1561. }
  1562.  
  1563. load_config()
  1564. {
  1565. FILE *fp;
  1566. int i;
  1567.  
  1568. if (!(fp=fopen("prism.cfg","r")))
  1569.     return();
  1570. fgets(path,80,fp);
  1571. if(!(strcmp(path,"VER1\n"))) {
  1572.     fgets(path,30,fp);
  1573.     for (i=0; i<30; i++)
  1574.         if (path[i]=='\n') path[i]='\0';            
  1575.     strcpy(WorkFont.ta_Name,path);
  1576.     fscanf(fp,"%d %d %d %d %d %d",&speed,&maxcolor,&read_dir,&lacemode,&sclearmode,&tabspace);
  1577.  
  1578.     if (sclearmode==0) SClear.Flags &= ~CHECKED;
  1579.  
  1580.     if (lacemode) {
  1581.         FirstWorkScreen.Height=420;
  1582.         FirstWorkScreen.ViewModes=HIRES|SPRITES|LACE;
  1583.         FirstWorkWindow.Height=400;
  1584.         maxheight=50;
  1585.         }
  1586.  
  1587.     switch(speed) {
  1588.         case 1: Fastest.Flags &= ~CHECKED;
  1589.             TFBaud.Flags |= CHECKED;
  1590.             break;
  1591.  
  1592.         case 2: Fastest.Flags &= ~CHECKED;
  1593.             TWBaud.Flags |= CHECKED;
  1594.             break;
  1595.  
  1596.         default: break;
  1597.         }
  1598.  
  1599.     switch(maxcolor) {
  1600.         case 15: FirstWorkScreen.Depth=4;
  1601.              break;
  1602.  
  1603.         case 7: FirstWorkScreen.Depth=3;
  1604.             Forplanes.Flags &= ~CHECKED;
  1605.             Threeplanes.Flags |= CHECKED;
  1606.             SelColor7.NextGadget = &FBStickGadget;
  1607.             break;
  1608.  
  1609.         case 3: FirstWorkScreen.Depth=2;
  1610.             Forplanes.Flags &= ~CHECKED;
  1611.             Twoplanes.Flags |= CHECKED;
  1612.             SelColor3.NextGadget = &FBStickGadget;
  1613.             break;
  1614.  
  1615.         default: break;
  1616.             }
  1617.     }
  1618. fclose(fp);
  1619. path[0]='\0';
  1620. }
  1621.